/******************************************************************************
 *  _____     _____
 *  \  __\    \  __\
 *   \ \_\\    \ \_\\
 *    \  __\SS  \  __\roject
 *     \_\       \_\
 *
 * Mateusz Maciąg, Rafał Urbański
 * Komputerowe Systemy Sterowania
 *****************************************************************************/

#include "SineWaveform.h"

#include <cmath>
#include <boost/math/constants/constants.hpp>

#include "Utils.h"

// Przestrzeń nazw
namespace RafMat
{
namespace SimEngine
{

using namespace std;
using namespace SimInterface;

const double PI = boost::math::constants::pi<double>();

SineWaveform::SineWaveform(ISimulator& sim,
                           double amplitude, double period,
                           double offset, double phase)
    : WaveformBase(sim, "Sine", "sine", amplitude, period, offset, phase)
{
}

double SineWaveform::getNextValue()
{
    double currentTime = getCurrentTime();
    return getGain() * sin(2*PI * currentTime / getPeriod() + getPhase()) + getOffset();
}

}   // SimEngine namespace
}   // RafMat namespace
